﻿@model Alma.Models.ProductDetailsModel

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewContext.Controller.ViewBag.Breadcrumb.Enter("Catégories", "Index", "Categories");
    ViewContext.Controller.ViewBag.Breadcrumb.Enter(Model.Name_Cat, "Show", "Category", new { id = Model.ID_Cat });
    ViewContext.Controller.ViewBag.Breadcrumb.Enter(Model.Name_Section, "Show", "Section", new { id = Model.ID_Section });
    ViewContext.Controller.ViewBag.Breadcrumb.Enter(Model.Name);

}

<div class="fullcol">
    <img alt="Product Illustration" class="productImg" src="@Url.Content(Model.ImgUrl)" />
    
    <ul style="float: right; list-style: none; margin: 0; padding: 0;">
    <li><a class="img" href="@Url.Action("Add", "Comparator", new { id = Model.ID })"><img alt="comparer le produit" src="@Url.Content("~/Content/style/buttonCompare.png")" /></a>
    </li>
    <li><a class="img" href="@Url.Action("Add", "Cart", new { id = Model.ID })"><img alt="ajouter au panier" src="@Url.Content("~/Content/style/buttonAdd.png")" /></a>
    </li>
 
    <li style="font-size: 11px;">
        <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=209740869069396&amp;xfbml=1"></script><fb:like href="" send="true" layout="button_count" width="150" show_faces="false" font="segoe ui"></fb:like>
    </li>
    
    <li style="font-size: 11px;">
        <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-lang="fr">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    </li>
    <li><g:plusone size="medium"></g:plusone></li>
    </ul>
    
    <h1>@Model.Name
    <span class="stars">
    @{
        float asc = (float)Math.Round(Model.score * 2) / 2f;
        for (int i = 0; i < 5; i++)
        {
            var imgName = asc > 0 ? (asc > 0.5 ? "fav-on.png" : "fav-demi.png") : "fav-off.png";
            <!-- TODO: jquery clicking on stars to give a score to the product -->
            <img alt="fav" src="@Url.Content("~/Content/images/" + imgName)" />
            asc -= 1f;
        }
        @: <span class="commentNote">(<a href="#comments">@Model.reviews.Count commentaires</a>)</span>
    }
    </span></h1>
    @*@Html.ActionLink("Editer", "Edit", "Product", new { id = Model.ID }, null)*@
    @*@Html.ActionLink("Comparer", "Add", "Comparator", new { id = Model.ID }, null) *@
    
    @if (Model.Price.HasValue)
    {
        <p>@Model.PriceCriterion.Name&nbsp;: <span class="price">@Model.Price.Value.ToString("0.00") @Model.PriceCriterion.Unit</span>
        <span style="display: block; font-size: 12px; color: #AAA;">
        <!-- TODO: price history -->
        @*<a href="#">Voir l'historique des prix</a>*@</span>
        </p>
        
    }
    else
    {
        <p>Le prix du produit n'est pas disponible.</p>
    }

    
    
    <!-- TODO: indicate stocks -->
    @if (Model.Availability == 1)
    {
        <p style="font-size: 18px; font-weight: bold; color: #5A5;">En stock.</p>
    }
    else if (Model.Availability == 2)
    {
        <p style="font-size: 18px; font-weight: bold; color: #C55;">Temporairement épuisé.</p>
    }
    else
    {
        <p style="font-size: 18px; font-weight: bold; color: #C55;">Indisponible.</p>
    }


        @*
    @if (Session["UserId"] != null)
    {
        @Html.ActionLink("Ajouter au panier", "Add", "Cart", new { id = Model.ID }, null)
    }
    else
    {
    @Html.ActionLink("Ajouter au panier", "Connect", "User")
    }
      *@
        
        <p>Fourni par @Html.ActionLink(Model.Name_Shop, "Show", "Shop", new { id = Model.ID_Shop }, null)</p>
    <!--<p>
        <strong>Point de vente&nbsp;:</strong> @Html.ActionLink(Model.Name_Shop, "Show", "Shop", new { id = Model.ID_Shop }, null)</p>-->
    <hr style="clear: both; border: 0; height: 1px;" />
    <h2>Description par le producteur</h2>
    <p>@Model.Description</p>
    <h2>Caractéristiques produit</h2>
    <table>
    @*
        <tr>
            <th>
                Note
            </th>
            <td>@Model.score/5
            </td>
        </tr> *@
        @foreach (var product in Model.CriterionList)
        {
            <tr>
                <th style="width: 300px;">@product.Item1
                </th>
                <td style="text-align: right; padding-right: 0;">@product.Item2
                </td>
                <td style="width: 50px;">@product.Item3
                </td>
            </tr>
        }
    </table>
    <br />
    <h2>Suggestions</h2>
    <!-- TODO: similar products -->

    <ul class="products">
        @foreach (var product in Model.Similars)
        {
            <li>
                <a href="@Url.Action("Show", "Product", new { id = product.ID })">
                <img src="@Url.Content(product.ImgUrl)" alt="@product.ImgUrl" />
                <span>@product.Name</span>
                
                </a>
            </li>
        }
    </ul>

    <h2 id="comments">Commentaires clients</h2>
    @if (Session["UserId"] == null)
    {
        <fieldset>
         <legend>Ajouter un commentaire</legend>
            Vous devez vous @Html.ActionLink("connecter", "Connect", "User") pour laisser un commentaire.
            </fieldset> 
    }
    else
    {
        using (Html.BeginForm("AddReview", "Product", FormMethod.Post, new { @encType = "multipart/form-data" }))
        {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>Ajouter un commentaire</legend>Note:<div class="editor-field">
                @Html.DropDownListFor(model => model.reviewScore, (ViewData["drop"] as SelectList))
                @Html.ValidationMessageFor(model => model.reviewScore)
            </div>
            Commentaire:<div class="editor-field">
                @Html.HiddenFor(model => model.ID)
                @Html.EditorFor(model => model.reviewText)
                @Html.ValidationMessageFor(model => model.reviewText)
            </div>
            <input type="submit" value="Ajouter" />
        </fieldset>
        }
    }
        <table>
            @foreach (var review in Model.reviews)
            {
                <tr>
                    <td>
                        Par <strong>@review.Name_User</strong> le @review.Date<br />
                        @review.Text
                    </td>
                </tr>
            }
        </table>

    <h2>Listes publiques</h2>
    @if (Model.Lists.Count == 0)
    {
    <p><em>Il n'y a pas de liste contenant ce produit.</em></p>
    <!-- TODO: public shopping lists -->
    }
    else
    {
        <ul>
        @foreach (var u in Model.Lists)
        {
            <li>@Html.ActionLink(u.List_Name, "Show", "List", new { id = u.ID }, null)</li>
        }
        </ul>
    }

</div>
